#pragma once
#include<iostream>
#include<vector>
using namespace std;

namespace lixixi {
	class bitset {
	public:
		bitset(size_t size)
		{
			_bt.resize(size / 32 + 1,0);
		}

		void set(size_t x)
		{
			size_t index = x / 32;
			size_t pos = x % 32;
			_bt[index] |= (1 << pos);
		}

		void reset(size_t x) 
		{
			size_t index = x / 32;
			size_t pos = x % 32;
			_bt[index] &= ~(1 << pos);
		}

		bool test(size_t x)
		{
			size_t index = x / 32;
			size_t pos = x % 32;
			return _bt[index] & (1 << pos);
		}

	private:
		vector<int> _bt;
	};

	void test_bitset()
	{
		bitset bt(100);
		bt.set(99);
		bt.set(4);
		bt.set(3);
		bt.set(6);
		bt.reset(6);
		for (size_t i = 0; i < 100; ++i)
		{
			printf("bit[%d]:%d\n", i, bt.test(i));
		}
	}

}